<head>
<title> UBCmatch - a place to match </title>
</head>
<center>
<a href="index.htm"><img src="logo.jpg"  border="0"/></a>
<form action="main.php" method="post"
enctype="multipart/form-data">
<br>
<label for="text">Enter your preferred name*:</label>
<input type="text" name="sender" />
</br>
<input type="submit" name="submit" value="Submit" />
</form>
*same name used for submitting ics.
<br><br>
<table border="1">
<tr>
<th>Class</th>
<th>You Share with</th>
</tr>

<?php
include("database.php");
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');
mysql_select_db($dbname);

	if($_POST['sender']!==""){
		$sender=$_POST['sender'];
		$sql="SELECT * FROM ubclass;";
		$res=mysql_query($sql);
		
		while($row=mysql_fetch_array($res)){
			if(str_replace($sender,"",$row['members'])!== $row['members']){
				$name=$row['name'];
				$members=$row['members'];
				echo "<tr> <td>$name</td> <td>$members</td> </tr> ";
				}
		
		}
		


	}
	else
	echo "enter a valid name";
?>
</table>
</center>